<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        font-size: 30px;
      }
    </style>
  </head>

  <body>
    <div>
      (min-width: 600px):
      <span style="color: red" id="mq-value"> </span>
    </div>
    <script>
      let mql = window.matchMedia("(min-width: 600px)");
      document.querySelector("#mq-value").innerText = mql.matches;

      mql.addEventListener("change", function () {
        mql = window.matchMedia("(min-width: 600px)");
        document.querySelector("#mq-value").innerText = mql.matches;
      });
    </script>
  </body>
</html>
